#!/usr/bin/env sh

scriptPath=${HOME}/.config/scripts

updateWeather() {
  WEATHER_CACHE=${HOME}/.cache/weather
  
  if [ ! -f ${WEATHER_CACHE} ]; then
    touch ${WEATHER_CACHE}
  fi
  
  WEATHER=$(curl -Ss 'https://wttr.in?format=3')
  if [ $? -eq 0 ] ; then
    echo ${WEATHER} | sed 's/ //g' > ${WEATHER_CACHE}
  fi
  
  COLOR=#FFFAFA
  
  echo -e "$(cat ${WEATHER_CACHE})($(date +"%H:%M"))\n\n${COLOR}"
}

updateWeather

case $BLOCK_BUTTON in
    1) updateWeather;;
esac
